// API统一管理
import requests from "./ajax";

// 引入mock请求
import mockRequests from './mockAjax'

// 三级联动接口
// axios发送请求返回的结果是Promise对象
// export const reqCategoryList = ()=>{
//   return requests({url:'/product/getBaseCategoryList',method:'get'})
// }
// 简化写法
// 获取三级分类数据
export const reqCategoryList = () => requests({ 
  url: '/product/getBaseCategoryList',
  method: 'get' 
})

// home首页轮播图
export const reqGetBannrList = () => mockRequests.get('/banner')

// 获取floor数据
export const reqFloorList = () => mockRequests.get('/floor')

// 获取搜索模块数据
export const reqGetSearchInfo = (params)=>requests({
  url:'/list',
  method:'post',
  data:params
})

// 获取商品详情数据
export const reqGetDetail = (skuid)=>requests({
  url:`/item/${skuid}`,
  method:'get'
})

// 添加购物车
export const reqAddShopcar =(skuId,skuNum)=>requests({
  url:`/cart/addToCart/${skuId}/${skuNum}`,
  method:'post'
}) 

// 获取购物车列表数据
export const reqGetShopCartList = ()=>requests({
  url :`/cart/cartList`,
  method:'get'
})

// 删除购物车产品
export const reqDeleteCartById = (skuId)=>requests({
  url :`/cart/deleteCart/${skuId}`,
  method:'delete'
})

 // 切换商品选中状态 /api/cart/checkCart/{skuID}/{isChecked}
 export const reqCheckCart = (skuId,isChecked)=>requests({
   url:`/cart/checkCart/${skuId}/${isChecked}`,
   method:'get'
 })

 // 获取验证码 [/api/user/passport/sendCode/{phone}]
 export const reqGetCode = (phone)=>requests({
  url:`/user/passport/sendCode/${phone}`,
  method:'get'
 })
 // 注册 /api/user/passport/register
 export const reqRegister = (params)=>requests({url:`/user/passport/register`,method:'post',data:params})

 // 登录 /api/user/passport/login post
 export const reqLogin = (phone,password)=>requests({
   url:`/user/passport/login`,
   method:'post',
   data:{
     phone,
     password
   }
 })


 // 携带token获取用户信息 http://182.92.128.115/api/user/passport/auth/getUserInfo
 export const reqUserInfo = ()=>requests({
   url:`/user/passport/auth/getUserInfo`,
   method:'get'
 })

  // 退出登录 /api/user/passport/logout
  export const reqLogout = ()=>requests({
    url:`/user/passport/logout`,
    method:'get'
  })